package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class WriteStringDemo {
    public static void main(String[] args) throws IOException {
//        append为true，后续添加数据，前数据不会被覆盖
        FileOutputStream fos=new FileOutputStream("fos.txt",true);
        String line="门前老树张新芽，院里古木又开花。";
        byte[] data=line.getBytes(StandardCharsets.UTF_8);
        fos.write(data);
        fos.write("半生存了好多话，藏进了满头白发.".getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        fos.close();
    }
}
